package com.yanqu.road.entity.activity.xiuxian.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_c_xiuxian_pvp_user_data")
public class CrossXiuXianPvpUserData extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "玩家ID", update = true)
    private long userId;

    @FieldTypeAnnotation(desc = "玩家pve属性")
    private XiuXianPveUserProperty pveProperty = new XiuXianPveUserProperty();

    @FieldTypeAnnotation(desc = "玩家pvp属性,生成/复活时就固定了")
    private XiuXianPvpUserProperty pvpProperty = new XiuXianPvpUserProperty();

    @FieldTypeAnnotation(desc = "宗门id")
    private int campId;

    @FieldTypeAnnotation(desc = "所在地点")
    private int placeId;

    @FieldTypeAnnotation(desc = "位置信息")
    private CrossXiuXianPvpPosition position = new CrossXiuXianPvpPosition();

    @FieldTypeAnnotation(desc = "可传送的时间")
    private long transferTime;

    @FieldTypeAnnotation(desc = "最后一次攻击时间")
    private long attackTime;

    @FieldTypeAnnotation(desc = "最后一次被攻击时间")
    private long attackedTime;

    @FieldTypeAnnotation(desc = "复活时间")
    private long reviveTime;

    @FieldTypeAnnotation(desc = "复活了多少次")
    private int reviveCnt;

    @FieldTypeAnnotation(desc = "属性更新时间")
    private long updatePropertyTime;

    @FieldTypeAnnotation(desc = "体力使用总数量")
    private int totalUseEnergy;

    @FieldTypeAnnotation(desc = "更新体力总数量时间")
    private long updateEnergyTime;

    @FieldTypeAnnotation(desc = "本条命战绩")
    private CrossXiuXianPvpBattleRecord battleRecord = new CrossXiuXianPvpBattleRecord();

    @FieldTypeAnnotation(desc = "历史战绩")
    private Map<Integer, CrossXiuXianPvpBattleRecord> battleRecordMap = new ConcurrentHashMap<>();


    @FieldTypeAnnotation(desc = "个人击杀总战绩")
    private long attackScore;

    @FieldTypeAnnotation(desc = "个人占点总战绩")
    private long seizeScore;


    @FieldTypeAnnotation(desc = "个人战绩更新时间")
    private long updateScoreTime;

    @FieldTypeAnnotation(desc = "房间心跳时间")
    private long lastPingPlaceTime;

    @FieldTypeAnnotation(desc = "分配信息")
    private CrossXiuXianUserMountData mountData = new CrossXiuXianUserMountData();

    @FieldTypeAnnotation(desc = "是否有资格参与pvp宗门大会")
    private boolean pvpAble;

    public CrossXiuXianPvpUserData() {

    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public CrossXiuXianPvpBattleRecord getBattleRecord() {
        return battleRecord;
    }

    public void setBattleRecord(CrossXiuXianPvpBattleRecord battleRecord) {
        if (battleRecord == null) {
            return;
        }
        this.battleRecord = battleRecord;
        setOp(DataStatus.Update);
    }

    public Map<Integer, CrossXiuXianPvpBattleRecord> getBattleRecordMap() {
        return battleRecordMap;
    }

    public void setBattleRecordMap(Map<Integer, CrossXiuXianPvpBattleRecord> battleRecordMap) {
        if (battleRecordMap == null) {
            return;
        }
        this.battleRecordMap = battleRecordMap;
        setOp(DataStatus.Update);
    }

    public XiuXianPveUserProperty getPveProperty() {
        return pveProperty;
    }

    public void setPveProperty(XiuXianPveUserProperty pveProperty) {
        if (null == pveProperty) {
            return;
        }
        this.pveProperty = pveProperty;
        setOp(DataStatus.Update);
        // 更新属性时间
        setUpdatePropertyTime(System.currentTimeMillis());
    }

    public XiuXianPvpUserProperty getPvpProperty() {
        return pvpProperty;
    }

    public void setPvpProperty(XiuXianPvpUserProperty pvpProperty) {
        if (null == pvpProperty) {
            return;
        }
        this.pvpProperty = pvpProperty;
        setOp(DataStatus.Update);
    }

    public int getCampId() {
        return campId;
    }

    public void setCampId(int campId) {
        if (this.campId != campId) {
            this.campId = campId;
            setOp(DataStatus.Update);
        }
    }

    public int getPlaceId() {
        return placeId;
    }

    public void setPlaceId(int placeId) {
        if (this.placeId != placeId) {
            this.placeId = placeId;
            setOp(DataStatus.Update);
        }
    }

    public CrossXiuXianPvpPosition getPosition() {
        return position;
    }

    public void setPosition(CrossXiuXianPvpPosition position) {
        if (null == position) {
            return;
        }
        this.position = position;
        setOp(DataStatus.Update);
    }

    public long getTransferTime() {
        return transferTime;
    }

    public void setTransferTime(long transferTime) {
        if (this.transferTime != transferTime) {
            this.transferTime = transferTime;
            setOp(DataStatus.Update);
        }
    }

    public long getAttackTime() {
        return attackTime;
    }

    public void setAttackTime(long attackTime) {
        if (this.attackTime != attackTime) {
            this.attackTime = attackTime;
            setOp(DataStatus.Update);
        }
    }

    public long getAttackedTime() {
        return attackedTime;
    }

    public void setAttackedTime(long attackedTime) {
        if (this.attackedTime != attackedTime) {
            this.attackedTime = attackedTime;
            setOp(DataStatus.Update);
        }
    }

    public long getReviveTime() {
        return reviveTime;
    }

    public void setReviveTime(long reviveTime) {
        if (this.reviveTime != reviveTime) {
            this.reviveTime = reviveTime;
            setOp(DataStatus.Update);
        }
    }

    public long getUpdatePropertyTime() {
        return updatePropertyTime;
    }

    public void setUpdatePropertyTime(long updatePropertyTime) {
        if (this.updatePropertyTime != updatePropertyTime) {
            this.updatePropertyTime = updatePropertyTime;
            setOp(DataStatus.Update);
        }
    }

    public int getReviveCnt() {
        return reviveCnt;
    }

    public void setReviveCnt(int reviveCnt) {
        if (this.reviveCnt != reviveCnt) {
            this.reviveCnt = reviveCnt;
            setOp(DataStatus.Update);
        }
    }

    public long getAttackScore() {
        return attackScore;
    }

    public void setAttackScore(long attackScore) {
        if (this.attackScore != attackScore) {
            this.attackScore = attackScore;
            setOp(DataStatus.Update);
        }
    }

    public long getSeizeScore() {
        return seizeScore;
    }

    public void setSeizeScore(long seizeScore) {
        if (this.seizeScore != seizeScore) {
            this.seizeScore = seizeScore;
            setOp(DataStatus.Update);
        }
    }

    public long getUpdateScoreTime() {
        return updateScoreTime;
    }

    public void setUpdateScoreTime(long updateScoreTime) {
        if (this.updateScoreTime != updateScoreTime) {
            this.updateScoreTime = updateScoreTime;
            setOp(DataStatus.Update);
        }
    }

    public long getLastPingPlaceTime() {
        return lastPingPlaceTime;
    }

    public void setLastPingPlaceTime(long lastPingPlaceTime) {
        if (this.lastPingPlaceTime != lastPingPlaceTime) {
            this.lastPingPlaceTime = lastPingPlaceTime;
            setOp(DataStatus.Update);
        }
    }

    /**
     * 获取用户状态  0 正常，1死亡
     */
    public int getUserState() {
        return pvpProperty.getHp() <= 0 || reviveTime > System.currentTimeMillis() ? 1 : 0;
    }

    public long getUpdateEnergyTime() {
        return updateEnergyTime;
    }

    public void setUpdateEnergyTime(long updateEnergyTime) {
        if (this.updateEnergyTime != updateEnergyTime) {
            this.updateEnergyTime = updateEnergyTime;
            setOp(DataStatus.Update);
        }
    }

    public int getTotalUseEnergy() {
        return totalUseEnergy;
    }

    public void setTotalUseEnergy(int totalUseEnergy) {
        if (this.totalUseEnergy != totalUseEnergy) {
            this.totalUseEnergy = totalUseEnergy;
            setOp(DataStatus.Update);
            // 更新时间
            setUpdateEnergyTime(System.currentTimeMillis());
        }
    }

    public CrossXiuXianUserMountData getMountData() {
        return mountData;
    }

    public void setMountData(CrossXiuXianUserMountData mountData) {
        if (mountData == null) {
            return;
        }
        this.mountData = mountData;
        setOp(DataStatus.Update);
    }

    public boolean isPvpAble() {
        return pvpAble;
    }

    public void setPvpAble(boolean pvpAble) {
        if (this.pvpAble != pvpAble) {
            this.pvpAble = pvpAble;
            setOp(DataStatus.Update);
        }
    }
}
